<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopGoodsStockWarningTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_goods_stock_warning', ['comment' => '商品库存预警', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('goods_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '商品'])
            ->addColumn('goods_sku_price_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '规格'])
            ->addColumn('goods_sku_text', 'string', ['limit'  =>  255, 'null' => true, 'default' => null, 'comment' => '规格名'])
            ->addColumn('stock_warning', 'integer', ['limit'  =>  10, 'default' => 0, 'comment' => '预警值'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->addColumn('delete_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '删除时间'])
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_goods_stock_warning');
        $table->drop();
    }
}
